import 'package:safetymonitor/generated/json/base/json_convert_content.dart';
import 'package:safetymonitor/app/data/entities/home/monitor/env_monitor_history_entity.dart';

EnvMonitorHistoryEntity $EnvMonitorHistoryEntityFromJson(Map<String, dynamic> json) {
  final EnvMonitorHistoryEntity envMonitorHistoryEntity = EnvMonitorHistoryEntity();
  final String? alarmStartTime = jsonConvert.convert<String>(json['alarmStartTime']);
  if (alarmStartTime != null) {
    envMonitorHistoryEntity.alarmStartTime = alarmStartTime;
  }
  final String? categoryEn = jsonConvert.convert<String>(json['categoryEn']);
  if (categoryEn != null) {
    envMonitorHistoryEntity.categoryEn = categoryEn;
  }
  final String? categoryZh = jsonConvert.convert<String>(json['categoryZh']);
  if (categoryZh != null) {
    envMonitorHistoryEntity.categoryZh = categoryZh;
  }
  final int? val = jsonConvert.convert<int>(json['val']);
  if (val != null) {
    envMonitorHistoryEntity.val = val;
  }
  return envMonitorHistoryEntity;
}

Map<String, dynamic> $EnvMonitorHistoryEntityToJson(EnvMonitorHistoryEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['alarmStartTime'] = entity.alarmStartTime;
  data['categoryEn'] = entity.categoryEn;
  data['categoryZh'] = entity.categoryZh;
  data['val'] = entity.val;
  return data;
}

extension EnvMonitorHistoryEntityExtension on EnvMonitorHistoryEntity {
  EnvMonitorHistoryEntity copyWith({
    String? alarmStartTime,
    String? categoryEn,
    String? categoryZh,
    int? val,
  }) {
    return EnvMonitorHistoryEntity()
      ..alarmStartTime = alarmStartTime ?? this.alarmStartTime
      ..categoryEn = categoryEn ?? this.categoryEn
      ..categoryZh = categoryZh ?? this.categoryZh
      ..val = val ?? this.val;
  }
}